#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
class isequall
{
public:
    explicit isequall(string &word) :_word(word) {}
    bool operator()(const std::pair<string, int> & rhs) const {return rhs.first == _word;}
private:
    string &_word;
};
int main()
{
    std::ifstream ifs("english.txt", std::ios::in);
    string line;
    vector<pair<string, int>> vec;
    while(getline(ifs, line), ifs.good())
    {
        istringstream iss(line);
        string word;
        while(iss >> word)
        {
            auto it = std::find_if(vec.begin(), vec.end(), isequall(word));
            if(it != vec.end())
            {
                it->second++;
            }
            else
            {
                vec.push_back(make_pair(word, 1));
            }
        }
    }

    for(auto & elem : vec)
    {
        cout << elem.first << " " << elem.second << endl;
    }
}
